package bgg4j;

import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class Game extends BggResponse {
	
	/*package*/Game(Element elem, Bgg bgg) throws BggException{
	        super(elem, bgg);
	}
	
	public int getGameID(){
		return Integer.valueOf(this.getAttributeText("gameid"));
	}
	
	public 
    /*package*/ static List<Game> constructGames(Document doc,
            Bgg bgg) throws BggException{
            if (null == doc) {
                return new ArrayList<Game> (0);
            } else {
                try {
                    ensureRootNodeNameIs("games", doc.getDocumentElement());
                    NodeList list = doc.getDocumentElement().getElementsByTagName(
                            "game");
                    int size = list.getLength();
                    List<Game> statuses = new ArrayList<Game>(size);
                    for (int i = 0; i < size; i++) {
                        Element status = (Element) list.item(i);
                        statuses.add(new Game(status, bgg));
                    }
                    return statuses;
                } catch (BggException te) {
                    return new ArrayList<Game>(0);
                }
            }
        }
	

}
